package teach.aistar.service.impl;






import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import teach.aistar.mapper.BuyCarsMapper;
import teach.aistar.model.entity.CarDetail;
import teach.aistar.model.vo.BuyCarsQueryVo;
import teach.aistar.model.vo.CarQueryVo;
import teach.aistar.model.vo.ProductQueryVo;
import teach.aistar.service.IBuyCarsService;

import java.util.List;
@Service
public class BuyCarsServiceImpl implements IBuyCarsService {
    @Autowired
    private BuyCarsMapper buyCarsMapper;


//    @Override
//    public PageInfo<CarDetail> findAll(CarQueryVo vo, Integer pageNow, Integer pageSize) {
//
//        PageHelper.startPage(pageNow,pageSize);
//
//////        List<Product> productList = productMapper.findByConditional(vo);
//        List<CarDetail> carDetail= buyCarsMapper.findAll();
//        PageInfo<CarDetail> pageInfo = new PageInfo<>(carDetail);
//
////        System.out.println(pageInfo);
//
//        return pageInfo;
//    }

    @Override
    public PageInfo<CarDetail> findAll(ProductQueryVo vo, Integer pageNow, Integer pageSize) {

        PageHelper.startPage(pageNow,pageSize);
        List<CarDetail> byConditionals = buyCarsMapper.findByConditionals(vo);
        PageInfo<CarDetail> pageInfo = new PageInfo<>(byConditionals);
        return pageInfo;
    }

    @Override
    public PageInfo<CarDetail> findAllx(Integer pageNow, Integer pageSize) {
        PageHelper.startPage(pageNow,pageSize);
        List<CarDetail> carDetail= buyCarsMapper.findAll();
        PageInfo<CarDetail> pageInfo = new PageInfo<>(carDetail);

//        System.out.println(pageInfo);

        return pageInfo;
    }

    @Override
    public PageInfo<CarDetail> findAllBy(Integer pageNow, Integer pageSize) {
        PageHelper.startPage(pageNow,pageSize);
        List<CarDetail> carDetails = buyCarsMapper.findby();
        PageInfo<CarDetail> pageInfo = new PageInfo<>(carDetails);
        return pageInfo;
    }

    @Override
    public int update(Integer id) {
        int x= buyCarsMapper.update(id);
        return x;
    }


    @Override
    public CarDetail findId(Integer id) {
        CarDetail carDetail = buyCarsMapper.findId(id);
        return carDetail;
    }

    @Override
    public PageInfo<CarDetail> findAge(Integer cAge,Integer pageNow, Integer pageSize) {
       List<CarDetail> carDetail = buyCarsMapper.findAge(cAge);
       PageInfo<CarDetail> pageInfo = new PageInfo<>(carDetail);
       return  pageInfo;
    }


}
